package com.rollCall.controller.app;

import com.rollCall.entity.vo.AppCheckInVo;
import com.rollCall.entity.result.Result;
import com.rollCall.service.app.AppStudentService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LiZhiHan
 * @date 2025/2/28
 */
@RestController
@RequestMapping("/user/checkIn")
@RequiredArgsConstructor
@Slf4j
@CrossOrigin
public class AppCheckInController {
	private final AppStudentService appStudentService;

	/**
	 * 条件获取签到列表
	 *
	 * @param status 0:未签到 1:已签到 2:已过期 -1:全部
	 */
	@PostMapping("/list/{status}")
	public Result<List<AppCheckInVo>> list(@PathVariable("status") Integer status) {
		return Result.success(appStudentService.list(status));
	}

	/**
	 * 签到
	 *
	 * @param checkInId 签到配置的 id
	 */
	@PostMapping("/{checkInId}")
	public Result<Void> checkIn(@PathVariable Long checkInId) {
		appStudentService.checkIn(checkInId);
		return Result.success();
	}
}
